package com.wang.tank;

import java.util.Vector;

/**
 * @author 王先锋
 * @version 1.0
 */
public class Hero extends Tank {
    //定义shot对象
    Shot shot = null;
    //可以发射多颗子弹
    Vector<Shot> shots = new Vector<>();

    public Hero(int x, int y) {
        super(x, y);
    }

    //射击
    public void shotEnemyTank() {
        //发多颗子弹，至多五颗
        if (shots.size() == 5) {
            return;
        }


        //创建shot对象，根据当前hero对象的位置和方向来创建shot
        switch (getDirect()) {
            case 0://向上
                shot = new Shot(getX() + 20, getY(), 0);
                break;
            case 1://向上
                shot = new Shot(getX() + 60, getY() + 20, 1);
                break;
            case 2://向上
                shot = new Shot(getX() + 20, getY() + 60, 2);
                break;
            case 3://向上
                shot = new Shot(getX(), getY() + 20, 3);
                break;
        }
        shots.add(shot);
        //启动shot线程
        new Thread(shot).start();
    }
}
